<?php

class M_kr_akun_level5 extends CI_Model {
    private $tbl_kr_akun_level5 = 'kr_akun_level5';
    public function __construct() {
        parent::__construct();
    }
    
    public function view() {
        $this->db->order_by('uniq_kode');
        $query = $this->db->get('kr_akun_level5');
        return $query->result();
    }
    
    public function insert($data){
        $this->db->insert('kr_akun_level5',$data);
    }
    
    public function get_by_kd($kd){
    return $this->db->where('uniq_kode',$kd)
            ->get($this->tbl_kr_akun_level5)
            ->row_array();
    }
    
    function update($kd = false) {
        foreach($_POST as $key => $val) {
                $data[$key] = $this->input->post($key);
        }
        if ($kd) {
                $this->db->where('uniq_kode', $kd);
                $this->db->update($this->tbl_kr_akun_level5, $data);
                return $this->db->affected_rows();
        } else {
                $this->db->insert($this->tbl_kr_akun_level5, $data);
                return $this->db->insert_id();
        }
    }
    
    public function delete($kd) {
        $this->db->where('uniq_kode',$kd);
        $this->db->delete($this->tbl_kr_akun_level5);
    }   
}
?>
